package com.qf.config;

import com.qf.pojo.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration  //相当于spring-context.xml  配置文件
public class UserConfig {
    /**
     * 实例化用户对象
     *
     * 方法名字 ==  id="user"
     * class == 返回值
     */
    @Bean(name = "user1")//构造一个实例,放到spring容器中   //相当于   <bean id="user" class=com.qf.pojo.User/>
    public User user(){
        User user = new User();
        user.setId(1);
        user.setName("张三");
        return user;
    }
}
